<?php
Class MyConfig extends CI_Model
{
	function get_config()
	{
		$this -> db -> select('config_id, default_max_score, default_num_question, default_time, modified_user, modified_date');
		$this -> db -> from('config');
		$this -> db -> limit(1);

		$query = $this -> db -> get();

		if($query -> num_rows() == 1)
		{
			return $query->row();
		}
		else
		{
			return false;
		}
	}
	
	function update_config($default_max_score, $default_num_question, $default_time, $modified_user)
	{
		date_default_timezone_set('Asia/Ho_Chi_Minh');
		$data = array (
			'default_max_score' => $default_max_score,
			'default_num_question' => $default_num_question,
			'default_time' => $default_time,
			'modified_user' => $modified_user,
			'modified_date' => date("Y/m/d H:i:s", time())
		);
		$this -> db -> update('config', $data);
		
		if($this->db->affected_rows() == 1)
			return true;
		else
			return false;
	}
}
?>